package Uno;

/**
 *
 * @author Sagor
 */
abstract class Card {
    protected final int[] number= new int [112];          //index of each card;
    protected final String[] type= new String [112];      //types of the cards: regular & power;
    protected int powerType;                        //21=skip, 22=reverse, 23=2+, 24=4+, 26=colorChange;
    protected final String color;                         //color of cards;
    protected int value= 0;                         //int value to assign values to each card;

    protected Card(String color)                    //constructor;
    {
        this.color= color;
    }

    //method initializeCards initializes values for regular and power cards according to index;

    protected void initializeCards(int i, int j, int type)  {
        while(i<j) {
            if(type==1) {
                for(value=0; value<10; value++)    {
                number[i]= value;
                i++;
                }
            }
            else if(type==2 && j<=103)  {
                    for(powerType=21; powerType<24; powerType++)    {
                        number[i]= powerType;
                        number[i+1]= powerType;
                        i+=2;
                    }
                }
            else    {
                for(powerType=24; powerType<26; powerType++)    {
                    for(int a=0; a<4; a++)    {
                        number[i]= powerType;
                        i++;
                    }
                    
                }
            }
        }
    }

    //method setType sets types of the cards according to their values;

    protected void setType()   {
        for(int i=0; i<112; i++)    {
            if(number[i]>=0 && number[i]<10)    {
                type[i]="Regular";
            }
            else    {
                type[i]="Power";
            }
        }
    }
}
